#include<bits/stdc++.h>
#define int long long
using namespace std;
int t;
int a[20];
int n;
int vis[20];
int ans;
int judge() {
    int sum = 0;
    for(int i = 2; i <= n; i++) {
        for(int j = i - 1; j >= 1; j--) {
            if(i != j && a[i] == a[j] && vis[i] == vis[j]) {
                sum += a[i];
            }
        }
    }
    return sum;
}
void dfs(int depth) {
    if(depth == n + 1) {
        ans = max(judge(), ans);
        return ;
    }
    vis[depth] = 1;
    dfs(depth + 1);
    vis[depth] = 0;
    dfs(depth + 1);
}
signed main() {
    freopen("color.in", "r", stdin);
    freopen("color.out", "w", stdout);
    cin >> t;
    while(t--) {
        ans = 0;
        memset(vis, 0, sizeof(vis));       
        cin >> n;
        for(int i = 1; i <= n; i++) {
            cin >> a[i];
        }
        dfs(1);
        cout << ans << '\n';
    }
    return 0;
}
